package chordcows;
import java.net.*;
import java.io.*;

/**
 *
 * @author chris day
 * @project everyonesBOX
 */
public class TransferServer implements Runnable {
	private String Directory;
	private int port;

	public TransferServer (String directory) {
		this.Directory = directory;
		this.port=2222;
	}
	
	public TransferServer (String directory, int port) {
		this.Directory = directory;
		this.port=port;
	}

	public void run() {
		try {
			ServerSocket servsock = new ServerSocket(port);

			while(true) {
				Socket clisock = servsock.accept();
				System.out.println("Socket received, spawning thread...");

				SocketHandler client = new SocketHandler(clisock, this.Directory);
				Thread t1 = new Thread(client);
				t1.start();
			}
		} catch (IOException ex) {
			System.err.println("Server creation failed: " + ex);
		}
	}
}